<template>
  <div class="user-dashboard">
    <div class="user-info-section">
      <h2>个人信息</h2>
      <div class="info-content">
        <div class="info-item">
          <span class="label">姓名：</span>
          <span class="value">{{ userInfo.name }}</span>
        </div>
        <div class="info-item">
          <span class="label">工号：</span>
          <span class="value">{{ userInfo.workId }}</span>
        </div>
        <div class="info-item">
          <span class="label">联系电话：</span>
          <span class="value">{{ userInfo.phone }}</span>
        </div>
      </div>
    </div>

    <el-row :gutter="20" class="status-cards">
      <el-col :span="12">
        <el-card class="status-card">
          <div class="status-number">{{ borrowStatus.pending }}</div>
          <div class="status-label">待归还器材</div>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card class="status-card">
          <div class="status-number">{{ borrowStatus.returned }}</div>
          <div class="status-label">已归还器材</div>
        </el-card>
      </el-col>
    </el-row>

    <el-card class="recent-activities">
      <template #header>
        <div class="card-header">
          <span>最近操作记录</span>
        </div>
      </template>
      <el-timeline>
        <el-timeline-item
          v-for="activity in recentActivities"
          :key="activity.id"
          :timestamp="activity.time"
          :type="activity.type"
        >
          {{ activity.content }}
        </el-timeline-item>
      </el-timeline>
    </el-card>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const userInfo = ref({
  name: '小明',
  workId: '20241008123',
  phone: '1808080123'
})

const borrowStatus = ref({
  pending: 3,
  returned: 2
})

const recentActivities = ref([
  {
    id: 1,
    content: '借用显微镜',
    time: '2024-12-11 10:20',
    type: 'primary'
  },
  {
    id: 2,
    content: '归还烧杯',
    time: '2024-12-10 15:30',
    type: 'success'
  }
])
</script>

<style scoped>
.user-dashboard {
  padding: 20px;
}

.user-info-section {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1);
}

.info-content {
  margin-top: 20px;
}

.info-item {
  margin-bottom: 15px;
  font-size: 16px;
}

.label {
  color: #606266;
  margin-right: 10px;
}

.value {
  color: #303133;
  font-weight: 500;
}

.status-cards {
  margin-bottom: 20px;
}

.status-card {
  text-align: center;
  padding: 20px;
}

.status-number {
  font-size: 36px;
  font-weight: bold;
  color: #409EFF;
  margin-bottom: 10px;
}

.status-label {
  color: #606266;
  font-size: 16px;
}

.recent-activities {
  margin-top: 20px;
}

.card-header {
  font-weight: bold;
}
</style>

